<div class="row">
  <div class="col-md-12">
    <div class="panel">
      <div class="panel-body">
        <%= simple_form_for @object, html: { class: "form-horizontal", role: "form"} do |f| %>

            <%= f.input :email %>

            <%= f.input :password %>

            <%= f.input :password_confirmation %>

            <table class="table table-striped">
              <thead>
                <tr>
                  <td>Menu</td>
                  <td>Operação</td>
                </tr>
              </thead>

              <tbody>
                <%= f.simple_fields_for :permissions do |permission| %>
                  <tr>
                    <td>
                      <%= I18n.t("controllers.#{permission.object.model}") %>
                      <%= permission.input :model, as: :hidden, value: permission.object.model %>
                    </td>
                    <td><%= permission.input :permission_type, as: :select, collection: WebAdmin::PermissionType.to_a, label: false %></td>
                  </tr>
                <% end %>
              </tbody>
            </table>

          <hr>
          <div class="form-actions">
            <%= f.submit 'Salvar', class: "btn btn-success" %>
            <%= link_to 'Apagar', @object, method: :delete, data: {confirm: 'Tem certeza que deseja remover esse registro?'}, class: 'btn btn-danger' if f.object.persisted? %>
            <% if can? :read, WebAdmin::User %>
              <%= link_to 'Cancelar', users_path, class: 'btn btn-primary' %>
            <% else %>
              <%= link_to 'Cancelar', root_path, class: 'btn btn-primary' %>
            <% end %>
          </div>
        <% end %>
      </div>
    </div>

  </div>
</div>
